<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-04-08
 * Time: 下午 3:05
 */

use Plug\Plug;
use Pub\cache\Cache;
use Pub\tool\Tool;

defined('IN_IA') or exit('Access Denied');
global $_GPC,$_W;
if($_W['container'] != 'wechat' || $_W['os'] != 'mobile'){
    message('本系统仅支持在手机端微信打开','','info');
    exit;
}

checkauth();

require MODULE_ROOT.'/vendor/autoload.php';

$_setting = pdo_get('kuyuan_vbz_setting',array('uniacid'=>$_W['account']['uniacid']),array('map_key','domain_defend'));

$_domain = array();  //防封域名

//酷源防封
if(!isset($_GPC['defend_jump']) && $_setting['domain_defend'] == 1){
    if($Plug = new Plug('defend')){
        $_domain = $Plug->get()->getDomain();
        header("Location:".Tool::parseRouter($_domain['url']));
        exit;
    }
}

/**
 * 解析router
 */
if(isset($_GPC['route']) && !isset($_GPC['wxref']) && strstr($_W['siteurl'],'%23%2F')){
    header("Location:".Tool::parseRouter($_W['siteurl'],true));
    exit;
}else if(isset($_GPC['wxref']) && isset($_GPC['route'])){
    header("Location:".Tool::parseRouter($_W['siteurl'],true));
    exit;
}else if(isset($_GPC['route']) && !isset($_GPC['wxref']) && strstr($_W['siteurl'],'%2523%252F')){
    $_url = Tool::parseRouter($_W['siteurl'],true);
    header("Location:".Tool::parseRouter($_url,true));
    exit;
}

//邀请用户添加好友
if(isset($_GPC['activity_id']) && isset($_GPC['share_uid']) && $_GPC['share_uid'] != 0){
    $_add_friend_sign = sha1($_GPC['activity_id'].'_'.$_W['member']['uid'].'_'.$_GPC['share_uid']);  //活动id+用户uid+添加用户好友的uid
    Cache::set(Cache::ADD_FRIEND_SIGN,$_add_friend_sign,array('id'=>$_GPC['activity_id'].'_'.$_W['member']['uid'].'_'.$_GPC['share_uid']));
}

include $this->template('index');